﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CamShared;
using System.Drawing;
using DavuxLib;

namespace TimestampFilter
{
    class TimestampFilter : ICameraFilter
    {

        int FontHeight = 0;
        string FontFamily = "";
        bool useLongString = true;

        public TimestampFilter()
        {
            FontHeight = Settings.Get("Video TimeStamp|Font Height", 16);
            FontFamily =  Settings.Get("Video TimeStamp|Font Family", "Tahoma");
            useLongString = Settings.Get("Video TimeStamp|Time With Seconds", true);
        }



        public System.Drawing.Image FrameReceived(ICamera camera, System.Drawing.Image frame)
        {
            if (!Settings.Get(camera.Name + "|Show Timestamp", true))
            {
                return frame;
            }



            using (Graphics g = Graphics.FromImage(frame))
            {
                if (useLongString)
                {
                    g.DrawString(DateTime.Now.ToLongTimeString(), new Font(FontFamily, FontHeight), Brushes.Yellow, new PointF(0, 0));
                }
                else
                {
                    g.DrawString(DateTime.Now.ToShortTimeString(), new Font(FontFamily, FontHeight), Brushes.Yellow, new PointF(0, 0));
                }
            }
            return frame;
        }

        public event CamShared.CamShared.RaiseRame OnNewFrame;

        public string Name
        {
            get { return "TimeStamp Filter"; }
        }

        public void Dispose()
        {

        }

    }
}
